﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for cls_tb_DIEM_DANH_HOCVIEN
/// </summary>
public class cls_tb_DIEM_DANH_HOCVIEN
{
	public cls_tb_DIEM_DANH_HOCVIEN()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public DataTable Chuongtrinh_GetByMACHN(string F_MACHN)
    {
        DataTable dt = new DataTable();
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        SqlParameter[] para = new SqlParameter[1];
        
        para[0] = new SqlParameter("@F_MACHN", F_MACHN);
        
        try
        {
            dt = connect.GetSelectCommand("tb_DIEM_DANH_HOCVIEN_Chuongtrinh_GetByF_MACHN", para);
        }
        catch { }
        return dt;
    }
    public DataTable Lop_GetByMaCN(string F_MACN)
    {
        DataTable dt = new DataTable();
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        SqlParameter[] para = new SqlParameter[1];
        para[0] = new SqlParameter("@F_MACN", F_MACN);
        
        try
        {
            dt = connect.GetSelectCommand("tb_DIEM_DANH_HOCVIEN_Lop_GetByMaCN", para);
        }
        catch { }
        return dt;
    }
    public DataTable Lop_GetByMaCN_MACHN_MACH(string F_MACN, string F_MACHN,string F_MACH)
    {
        DataTable dt = new DataTable();
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        SqlParameter[] para = new SqlParameter[3];
        para[0] = new SqlParameter("@F_MACN", F_MACN);
        para[1] = new SqlParameter("@F_MACHN", F_MACHN);
        para[2] = new SqlParameter("@F_MACH", F_MACH);
        try
        {
            dt = connect.GetSelectCommand("tb_DIEM_DANH_HOCVIEN_Lop_GetByMaCN_F_MACHN_F_MACH", para);
        }
        catch { }
        return dt;
    }
    public DataTable Hocvien_getby_Malop_ngay(string F_MALOP, DateTime F_NGAY)
    {
        DataTable dt = new DataTable();
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        SqlParameter[] para = new SqlParameter[2];
        para[0] = new SqlParameter("@F_MALOP", F_MALOP);
        para[1] = new SqlParameter("@F_NGAY", F_NGAY);
        try
        {
            dt = connect.GetSelectCommand("tb_DIEM_DANH_HOCVIEN_Hocvien_GetByMaLop_NGAY", para);
        }
        catch { }
        return dt;
    }
    public DataTable Hocvien_getby_Malop(string F_MALOP)
    {
        DataTable dt = new DataTable();
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        SqlParameter[] para = new SqlParameter[1];
        para[0] = new SqlParameter("@F_MALOP", F_MALOP);
        
        try
        {
            dt = connect.GetSelectCommand("tb_DIEM_DANH_HOCVIEN_Hocvien_GetByMaLop", para);
        }
        catch { }
        return dt;
    }
    public DataTable chitietvang_getby_Malop_MaHV(string F_MALOP, string F_MAHV)
    {
        DataTable dt = new DataTable();
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        SqlParameter[] para = new SqlParameter[2];
        para[0] = new SqlParameter("@F_MALOP", F_MALOP);
        para[1] = new SqlParameter("@F_MAHV", F_MAHV);

        try
        {
            dt = connect.GetSelectCommand("tb_DIEM_DANH_HOCVIEN_chitietvang_GetByMaLop_MaHV", para);
        }
        catch { }
        return dt;
    }
    public void Insert_list_hocvien_khong_vang(string F_MALOP, DateTime F_NGAY)
    {
        DatabaseConnect connect = new DatabaseConnect();
        SqlParameter[] para = new SqlParameter[2];
        para[0] = new SqlParameter("@F_MALOP", F_MALOP);
        para[1] = new SqlParameter("@F_NGAY", F_NGAY);

        try
        {
            connect.ExecuteQuery("tb_DIEM_DANH_HOCVIEN_InsertList_khongvang", para);
        }
        catch
        { }
    }
    //public void Update(int F_ID, string F_MAHV, string F_MALOP, DateTime F_NGAY, int F_VANG_P, int F_VANG_K,string F_VANG_P1, string F_VANG_K1, string F_LIDO)
    //{
    //    DatabaseConnect connect = new DatabaseConnect();
    //    SqlParameter[] para = new SqlParameter[9];
    //    para[0] = new SqlParameter("@F_ID", F_ID);
    //    para[1] = new SqlParameter("@F_MAHV", F_MAHV);
    //    para[2] = new SqlParameter("@F_MALOP", F_MALOP);
    //    para[3] = new SqlParameter("@F_NGAY", F_NGAY);
    //    para[4] = new SqlParameter("@F_VANG_P", F_VANG_P);
    //    para[5] = new SqlParameter("@F_VANG_K", F_VANG_K);
    //    para[6] = new SqlParameter("@F_VANG_P1", F_VANG_P1);
    //    para[7] = new SqlParameter("@F_VANG_K1", F_VANG_K1);
    //    para[8] = new SqlParameter("@F_LIDO", F_LIDO);

    //    try
    //    {
    //        connect.ExecuteQuery("tb_DIEM_DANH_HOCVIEN_Update", para);
            
    //    }
    //    catch
    //    {  }
    //}
    public string Update(int F_ID, string F_MAHV, string F_MALOP, DateTime F_NGAY, int F_VANG_P, int F_VANG_K, string F_VANG_P1, string F_VANG_K1, string F_LIDO)
    {
        DatabaseConnect connect = new DatabaseConnect();
        SqlParameter[] para = new SqlParameter[9];
        para[0] = new SqlParameter("@F_ID", F_ID);
        para[1] = new SqlParameter("@F_MAHV", F_MAHV);
        para[2] = new SqlParameter("@F_MALOP", F_MALOP);
        para[3] = new SqlParameter("@F_NGAY", F_NGAY);
        para[4] = new SqlParameter("@F_VANG_P", F_VANG_P);
        para[5] = new SqlParameter("@F_VANG_K", F_VANG_K);
        para[6] = new SqlParameter("@F_VANG_P1", F_VANG_P1);
        para[7] = new SqlParameter("@F_VANG_K1", F_VANG_K1);
        para[8] = new SqlParameter("@F_LIDO", F_LIDO);

        try
        {
            connect.ExecuteQuery("tb_DIEM_DANH_HOCVIEN_Update", para);
            return "OK";
        }
        catch
        { return "ERR"; }
    }
}